package com.tg.service.base.common;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;

public class ContextUtil {

    private static final ContextUtil CONTEXT_UTIL = new ContextUtil();

    private ApplicationContext context;

    private BeanFactory beanFactory;

    public static ContextUtil getInstance() {
        return CONTEXT_UTIL;
    }

    public void setContext(ApplicationContext context) {
        this.context = context;
    }

    public void setBeanFactory(BeanFactory beanFactory) {
        this.beanFactory = beanFactory;
    }

    public Object getBean(String beanName) {
        return this.context.getBean(beanName);
    }

    public Object getBeanFromFactory(String beanName){
        return this.beanFactory.getBean(beanName);
    }
}
